/**
 * Copyright (c) 2015-2030 by Beijing Yanlight Co., Ltd.
 * All rights reserved.
 */
package com.yanlight.util;

import com.yanlight.Constants;
import com.yanlight.app.dal.entity.Developer;
import com.yanlight.support.DevTokenHolder;

/**
 * 
 * @author haolw
 * @time 2018/02/08
 */
public abstract class DevTokenUtil {

	public static Developer get() {
		return JsonUtil.parse(get(DevTokenHolder.get()), Developer.class);
	}

	public static String get(String key) {
		return JedisUtil.get(generateKey(key));
	}
	
	public static Developer getAndResolve(String key) {
		return JsonUtil.parse(get(key), Developer.class);
	}

	public static boolean exists(String token) {
		return JedisUtil.exists(generateKey(token));
	}

	private static String generateKey(String key) {
		return Constants.DEV_TOKEN_CACHE_PREFIX.concat(key);
	}

}
